import 'package:tender_flutter/page/home/model/tender_entity.dart';
import 'package:tender_flutter/page/home/model/common_tag_model.dart';

tenderTagPageEntityFromJson(TenderTagPageEntity data, Map<String, dynamic> json) {
	if (json['dh'] != null) {
		data.dh = new List<CommonTagModel>();
		(json['dh'] as List).forEach((v) {
			data.dh.add(new CommonTagModel().fromJson(v));
		});
	}
	if (json['pageinfo'] != null) {
		data.pageinfo = new TenderEntity().fromJson(json['pageinfo']);
	}
	return data;
}

Map<String, dynamic> tenderTagPageEntityToJson(TenderTagPageEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	if (entity.dh != null) {
		data['dh'] =  entity.dh.map((v) => v.toJson()).toList();
	}
	if (entity.pageinfo != null) {
		data['pageinfo'] = entity.pageinfo.toJson();
	}
	return data;
}

tenderEntityFromJson(TenderEntity data, Map<String, dynamic> json) {
	if (json['pageNum'] != null) {
		data.pageNum = json['pageNum'] is String
				? int.tryParse(json['pageNum'])
				: json['pageNum'].toInt();
	}
	if (json['pageSize'] != null) {
		data.pageSize = json['pageSize'] is String
				? int.tryParse(json['pageSize'])
				: json['pageSize'].toInt();
	}
	if (json['total'] != null) {
		data.total = json['total'] is String
				? int.tryParse(json['total'])
				: json['total'].toInt();
	}
	if (json['pages'] != null) {
		data.pages = json['pages'] is String
				? int.tryParse(json['pages'])
				: json['pages'].toInt();
	}
	if (json['list'] != null) {
		data.xList = new List<TenderList>();
		(json['list'] as List).forEach((v) {
			data.xList.add(new TenderList().fromJson(v));
		});
	}
	if (json['isFirstPage'] != null) {
		data.isFirstPage = json['isFirstPage'];
	}
	if (json['isLastPage'] != null) {
		data.isLastPage = json['isLastPage'];
	}
	return data;
}

Map<String, dynamic> tenderEntityToJson(TenderEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['pageNum'] = entity.pageNum;
	data['pageSize'] = entity.pageSize;
	data['total'] = entity.total;
	data['pages'] = entity.pages;
	if (entity.xList != null) {
		data['list'] =  entity.xList.map((v) => v.toJson()).toList();
	}
	data['isFirstPage'] = entity.isFirstPage;
	data['isLastPage'] = entity.isLastPage;
	return data;
}

tenderListFromJson(TenderList data, Map<String, dynamic> json) {
	if (json['date'] != null) {
		data.date = json['date'].toString();
	}
	if (json['address'] != null) {
		data.address = json['address'].toString();
	}
	if (json['companyName'] != null) {
		data.companyName = json['companyName'].toString();
	}
	if (json['zbCompanyName'] != null) {
		data.zbCompanyName = json['zbCompanyName'].toString();
	}
	if (json['isFocus'] != null) {
		data.isFocus = json['isFocus'];
	}
	if (json['words'] != null) {
		data.words = json['words']?.map((v) => v.toString())?.toList()?.cast<String>();
	}
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['typeCode'] != null) {
		data.typeCode = json['typeCode'] is String
				? int.tryParse(json['typeCode'])
				: json['typeCode'].toInt();
	}
	if (json['bidding_id'] != null) {
		data.bidding_id = json['bidding_id'] is String
				? int.tryParse(json['bidding_id'])
				: json['bidding_id'].toInt();
	}
	if (json['untagContent'] != null) {
		data.untagContent = json['untagContent'].toString();
	}
	if (json['title'] != null) {
		data.title = json['title'].toString();
	}
	if (json['biddingClass'] != null) {
		data.biddingClass = json['biddingClass'].toString();
	}
	if (json['industry'] != null) {
		data.industry = json['industry'].toString();
	}
	if (json['price'] != null) {
		data.price = json['price'].toString();
	}
	if (json['type'] != null) {
		data.type = json['type'].toString();
	}
	return data;
}

Map<String, dynamic> tenderListToJson(TenderList entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['date'] = entity.date;
	data['address'] = entity.address;
	data['companyName'] = entity.companyName;
	data['zbCompanyName'] = entity.zbCompanyName;
	data['isFocus'] = entity.isFocus;
	data['words'] = entity.words;
	data['id'] = entity.id;
	data['typeCode'] = entity.typeCode;
	data['bidding_id'] = entity.bidding_id;
	data['untagContent'] = entity.untagContent;
	data['title'] = entity.title;
	data['biddingClass'] = entity.biddingClass;
	data['industry'] = entity.industry;
	data['price'] = entity.price;
	data['type'] = entity.type;
	return data;
}